<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>个人资料</title>
		<!-- 引入样式 -->
		<link rel="stylesheet" type="text/css" href="css/site.css" />
		<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vant@1.6/lib/index.css">
		<!-- 引入组件 -->
		<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.min.js"></script>
		<script src="https://cdn.jsdelivr.net/npm/vant@1.6/lib/vant.min.js"></script>
	</head>
	<body>
		<div id="app">
			<!-- 头部 -->
			<van-nav-bar id="S_bar" fixed=true title="修改昵称" left-arrow right-text="完成" @click-left="onClickLeft" @click-right="onClickRight"></van-nav-bar>
			<!-- 内容 -->
			<van-cell-group class="profile_group">
				<van-field type="text" v-model="NickName" :placeholder="placeholder"></van-field>
			</van-cell-group>
		</div>
		<script src="js/ajax.js"></script>
		<script src="html5plus://ready"></script>
		<script>
			var vm = new Vue({
				el: "#app",
				data: {
					placeholder: "",
					NickName:""
				},
				methods: {
					onClickLeft() {
						plus.webview.close(plus.webview.currentWebview());
					},
					onClickRight(){
						var _this = this
						ajax({
							url: "http://dsapi.ysd3g.com/API/ChangeNickName",
							data: {
								key: localStorage.getItem('Key'),
								nickName:_this.NickName
							},
							dataType: "jsonp",
							success: function(res) {
								console.log(res)
								if(!res.Error){
									alert("上传成功");
									var userData1 = JSON.parse(localStorage.getItem("userData1"));
									userData1.UserData.NickName = _this.NickName;
									localStorage.setItem('userData1', JSON.stringify(userData1));
									
									plus.webview.getWebviewById("userIndex").reload(true);
									plus.webview.getWebviewById("profile").reload(true);
									plus.webview.close(plus.webview.currentWebview(),"slide-out-right");
								}
							}
						})
					}
				},
				mounted() {
					var userData1 = JSON.parse(localStorage.getItem("userData1"));
					this.placeholder = userData1.UserData.NickName;
				}
			})
		</script>
	</body>
</html>
